<?php
// 脚本SQL语句快捷生成
// 
// 


$petname = '';
$petid = 0;
$petitemid = 0;

function action_petunlock($name, $id, $petitemid, $aid = 0, $fullname = '') {
	for($i = 1;$i<=11;$i++){
		$action[$i] = $aid++;
	}
	
	if($fullname == '') $fullname = $name;
	$sqltemp = 'insert into `cq_action` (`id`, `id_next`, `id_nextfail`, `type`, `data`, `param`) 
		VALUES ("'.$action[1].'", "'.$action[2].'", "'.$action[3].'", "503", "'.$petitemid.'", ""),
			("'.$action[3].'", "0", "0", "1010", "2024", "解锁'.$name.'跟宠必须有'.$name.'跟宠解锁卡"),
			("'.$action[2].'", "'.$action[4].'", "'.$action[5].'", "1978", "'. $id .'", ""),
			("'.$action[4].'", "0", "0", "1010", "2024", "您已经解锁了'.$fullname.'，请不要重复解锁"),
			("'.$action[5].'","'.$action[6].'","0","101","0", "尊敬的%user_name，这是一张珍贵的'.$name.'跟宠解锁卡，是否确定要解锁跟宠'.$fullname.'"),
			("'.$action[6].'","'.$action[7].'","0","102","0", "确定解锁。 '.$action[9].'"),
			("'.$action[7].'","'.$action[8].'","0","102","0", "我还是再考虑考虑。 0"),
			("'.$action[8].'","0","0","120","0", ""),
			("'.$action[9].'", "'.$action[10].'", "'.$action[3].'", "502", "'.$petitemid.'", ""),
			("'.$action[10].'", "'.$action[11].'", "", "1979", "'. $id .'", ""),
			("'.$action[11].'", "0", "0", "1010", "2024", "恭喜阁下已经成功解锁跟宠'.$fullname.'。");';
	$sql2 = "INSERT INTO `cq_task` (`id`, `id_next`, `sex`, `min_pk`, `max_pk`, `team`) VALUES ('{$action[9]}', '{$action[9]}', '999', '-100000', '100000', '999');";
	//还得加一句update
	$sql3 = "UPDATE `cq_itemtype` SET `id_action`='{$action[1]}' WHERE (`id`='{$petitemid}');";
	echo $sqltemp."\r\n".$sql2."\r\n".$sql3."\r\n\r\n\r\n";
	return $aid;
}
header('content-type:text/html;charset=utf-8');
$petinfo = array(
		array('name' => '维尼', 'id' => '1', 'itemid' => '753804', 'fullname' => '小小杰士·维尼'),
		array('name' => '潘潘', 'id' => '2', 'itemid' => '752992',   'fullname' => '万宝袋·潘潘'),
		array('name' => '斑比', 'id' => '3', 'itemid' => '752910', 'fullname' => '霜雪小鹿·斑比'),
		array('name' => '菲菲', 'id' => '5', 'itemid' => '753801',  'fullname' => '萌骑士·菲菲'),
		array('name' => '大卫', 'id' => '6', 'itemid' => '753302',  'fullname' => '胡桃夹子·大卫'),
		array('name' => '夏尔', 'id' => '7', 'itemid' => '753383',  'fullname' => '泡芙先生·夏尔'),
		array('name' => '南希', 'id' => '8', 'itemid' => '753384', 'fullname' => '泡芙小姐·南希'),
		array('name' => '鹿鹿', 'id' => '9', 'itemid' => '753933', 'fullname' => '小樱宝·鹿鹿'),
		//array('name' => '', 'id' => '', 'itemid' => '', 'fullname' => ''),
	);
$aid = 2018162900;
foreach($petinfo as $v)
{

	$aid = action_petunlock($v['name'],$v['id'],$v['itemid'],$aid,$v['fullname']);
}